import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
/* import * as mongoose from 'mongoose' */
import { ValidationPipe } from '@nestjs/common';

async function bootstrap() {
  /* await mongoose.connect('mongodb://localhost:27017/',{
    useNewUrlParser:true,
    useFindAndModify:false,
    useCreateIndex:true
  }) */
  const app = await NestFactory.create(AppModule);
  //验证管道
  app.useGlobalPipes(new ValidationPipe())

  const options = new DocumentBuilder()
    .setTitle('nest blog api')
    .setDescription('nestjs app')
    .setVersion('1.0')
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api-docs', app, document);

  await app.listen(5000);
}
bootstrap();
